package gameserver.model.items;

import javolution.util.FastList;

public enum ItemSlot
{
	HEADWEAR(1),
	WAIST(1<<1),
	PANTS(1<<2),
	NECKLACE(1<<3),
	BOOTS(1<<4),
	EARRINGS(1<<5),//should I identify left or right?
	RING_LEFT(1<<6),
	RING_RIGHT(1<<7),
	BANGLE_LEFT(1<<8),
	BANGLE_RIGHT(1<<9),
	
	WINGS(1<<10),
	NONE(1<<11),
	ALL(1<<12);
	
	private int slotIdMask;
	
	private ItemSlot(int _slotIdMask)
	{
		this.slotIdMask = _slotIdMask;
	}
	
	public int getSlotMask()
	{
		return slotIdMask;
	}
	
	public static FastList<ItemSlot> getSlotsFor(int slotIdMask)
	{
		FastList<ItemSlot> slots = new FastList<ItemSlot>();
		for(ItemSlot itemSlot : values())
		{
			int sumMask = itemSlot.slotIdMask & slotIdMask;
			if(sumMask > 0 && sumMask <= slotIdMask)
				slots.add(itemSlot);
		}
		if(slots.size() == 0)
			throw new IllegalArgumentException("Invalid provided slotIdMask " + slotIdMask);
		return slots;
	}
	
	public static void main(String[] args)
	{
		FastList<ItemSlot> slots = getSlotsFor(2048);
		System.out.println(slots.size());
		System.out.println(slots.get(0));
	}
	
	
}
